<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>列表控件属性</title>
    <base href="../../../../../"/>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" >
    <meta name="generator" content="www.leipi.org" />
    <link rel="stylesheet" href="plug-in/Formdesign/js/ueditor/formdesign/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="plug-in/Formdesign/js/ueditor/formdesign/leipi.style.css">
    <script type="text/javascript" src="plug-in/Formdesign/js/ueditor/formdesign/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="plug-in/Formdesign/js/ueditor/dialogs/internal.js"></script>
<script type="text/javascript">
function createElement(type, name)
{     
    var element = null;     
    try {        
        element = document.createElement('<'+type+' name="'+name+'">');     
    } catch (e) {}   
    if(element==null) {     
        element = document.createElement(type);     
        element.name = name;     
    } 
    return element;
}
</script>
 
</head>
<body>
<div class="content">
    <table class="table table-striped">
    <thead>
        <tr>
            <td> 
                <span> 控件名称 ：</span> 
                <input id="orgname" placeholder="必填项" type="text" class="input-medium" value=""/> <span class="label label-important">*</span>
            </td>
            <td> 
                <span> 数据源 ：</span> 
           	  		<select id="datasource"></select>
            </td>
             <td>
                                      宽 <input id="orgwidth" type="text" value="100%" class="input-small span1" placeholder="auto"/> % 或 px
            </td>
            
        </tr>
        <tr>
        	<td>
        		<span> 外键字段  ：</span>
        		<input type="text" id="pkid" placeholder="无则不填" class="input-medium"> 
        	</td>
        	<td colspan="2">
        		<span> 关联数据源字段 ：</span>
        		<input type="text" id="fkdsid" placeholder="无则不填" style="width: 200px" class="input-medium"> 
        	</td>
        </tr>
    </thead>
</table>


            <table class="table table-striped table-bordered table-condensed"  id="tbl">
            	  <thead>
	                <tr>
	                	<td colspan="11"><span class="pull-right"><button id="listAdd" class="btn btn-small btn-success listAdd" type="button">添加一行</button></span></td>
	                </tr>
                    <tr>
                        <th width="5%"> <span style='width:40px;display:block;'>序号</span> </th>
                        <th width="12%"> <span>表头</span> </th>
                        <th width="10%"> <span>类型</span> </th>
                        <th width="12%"> <span>字段</span> </th>
                        <th width="8%"> <span>长度</span> <a id="showTips" title="该列数据类型只允许数值类型" rel="popover"><i class="icon-info-sign"></i></a></th>
                        <th width="10%"> <span>单位</span> </th>
                        <th width="10%"> <span>数据字典</span> </th>
                        <th width="7%"> <span style='width:60px;display:block;'><span>合计</span> <a id="showCountTips" title="在该列的底部显示该列的合计数值，数据类型只允许数值类型" rel="popover"><i class="icon-info-sign"></i></a></span> </th>
                        <th width="7%"> <span>默认值</span> </th>
                        <th width="7%"><span>校验规则</span></th>
                        <th width="5%"> <span style='width:40px;display:block;'>隐藏</span> </th>
                        <th width="7%"> <span style='width:40px;display:block;'>操作</span> </th>
                    </tr>
                </thead>
                <tbody id="tbl1">
                    <tr>
                        <td><span class="badge">1</span></td>
                        <td title="Tab键切换输入框"> <input id="item_1" type="text" class="input-mini" style="width: 90%"> </td>
                        <td title="Tab键切换输入框">
                            <select id="coltype_1" class="input-medium" style="width: 100%">
                                <option value="text">单行输入框</option>
                                <option value="textarea">多行输入框</option>
                                <option value="int">数值</option>
                                <option value='radio'>单选按钮</option>
						        <option value='select'>下拉框</option>
						        <option value='checkbox'>复选框</option>
						        <option value='popup'>popup控件</option>
                            </select>
                        </td>
                         <td title="Tab键切换输入框"> 
                         	<label>
                         		<select id="field_1" class="input-medium" style="width: 100%">
	                                <option value="">选择数据源</option>
                                </select>
                        	</label> 
                         </td>
                        <td title="Tab键切换输入框"> <label><input type="text" class="input-mini" id="length_1" value=""> </label> </td>
                        <td title="Tab键切换输入框"> <label><input type="text" class="input-mini" id="unit_1" value=""> </label> </td>
                        <td title="Tab键切换输入框"> <label><input type="text" class="input-mini" id="dict_1" value=""> </label> </td>
                        <td title="Tab键切换输入框"> <label> <input type="checkbox" id="sum_1" class="csum" value="1"> </label> </td>
                        <td title="Tab键切换输入框"><input id="colvalue_1"  type="text" class="input-mini"/></td>
                        <td title="Tab键切换输入框"><input id="ruletype_1"  type="text" class="input-mini"/></td>
                        <td title="Tab键切换输入框"> <label> <input type="checkbox" id="isHide_1" value="1"> </label> </td>
                        <td></td>
                    </tr>
					<!-- 
                    <tr>
                        <td><span class="badge">2</span></td>
                        <td title="Tab键切换输入框"> <input id="item_2" type="text" class="input-medium"> </td>
                        <td title="Tab键切换输入框">
                            <select id="coltype_2" class="input-medium">
                                <option value="text">单行输入框</option>
                                <option value="textarea">多行输入框</option>
                                <option value="int">数值</option>
                                
                            </select>
                        </td>
                        <td title="Tab键切换输入框"> <label><input type="text" class="input-mini" id="field_2" value=""> </label> </td>
                        <td title="Tab键切换输入框"> <label><input type="text" class="input-mini" id="unit_2" value=""> </label> </td>
                        <td title="Tab键切换输入框"> <label> <input type="checkbox" id="sum_2" class="csum" value="2"> </label> </td>
                        <td title="Tab键切换输入框"><input id="colvalue_2"  type="text" class="input-medium"/></td>
                        <td title="Tab键切换输入框"> <label> <input type="checkbox" id="isHide_2" value="2"> </label> </td>
                        <td><label> <a>删除</a> </label> </td>
                    </tr>
                    
                    <tr>
                        <td><span class="badge">3</span></td>
                        <td title="Tab键切换输入框"> <input id="item_3" type="text" class="input-medium"> </td>
                        <td title="Tab键切换输入框">
                            <select id="coltype_3" class="input-medium">
                                <option value="text">单行输入框</option>
                                <option value="textarea">多行输入框</option>
                                <option value="int">数值</option>
                            </select>
                        </td>
                        <td title="Tab键切换输入框"> <label><input type="text" class="input-mini" id="field_3" value=""> </label> </td>
                        <td title="Tab键切换输入框"> <label><input type="text" class="input-mini" id="unit_3" value=""> </label> </td>
                        <td title="Tab键切换输入框"> <label> <input type="checkbox" id="sum_3" class="csum" value="3"> </label> </td>
                        <td title="Tab键切换输入框"><input id="colvalue_3"  type="text" class="input-medium"/></td>
                        <td title="Tab键切换输入框"> <label> <input type="checkbox" id="isHide_3" value="3"> </label> </td>
                        <td><label> <a>删除</a> </label> </td>
                    </tr>
                    <tr>
                        <td><span class="badge">4</span></td>
                        <td title="Tab键切换输入框"> <input id="item_4" type="text" class="input-medium"> </td>
                        <td title="Tab键切换输入框">
                            <select id="coltype_4" class="input-medium">
                                <option value="text">单行输入框</option>
                                <option value="textarea">多行输入框</option>
                                <option value="int">数值</option>
                            </select>
                        </td>
                        <td title="Tab键切换输入框"> <label><input type="text" class="input-mini" id="field_4" value=""> </label> </td>
                        <td title="Tab键切换输入框"> <label><input type="text" class="input-mini" id="unit_4" value=""> </label> </td>
                        <td title="Tab键切换输入框"> <label> <input type="checkbox" id="sum_4" class="csum" value="4"> </label> </td>
                        <td title="Tab键切换输入框"><input id="colvalue_4"  type="text" class="input-medium"/></td>
                        <td title="Tab键切换输入框"> <label> <input type="checkbox" id="isHide_4" value="4"> </label> </td>
                        <td><label> <a>删除</a> </label> </td>
                    </tr>
                    <tr>
                        <td><span class="badge">5</span></td>
                        <td title="Tab键切换输入框"> <input id="item_5" type="text" class="input-medium"> </td>
                        <td title="Tab键切换输入框">
                            <select id="coltype_5" class="input-medium">
                                <option value="text">单行输入框</option>
                                <option value="textarea">多行输入框</option>
                                <option value="int">数值</option>
                            </select>
                        </td>
                        <td title="Tab键切换输入框"> <label><input type="text" class="input-mini" id="field_5" value=""> </label> </td>
                        <td title="Tab键切换输入框"> <label><input type="text" class="input-mini" id="unit_5" value=""> </label> </td>
                        <td title="Tab键切换输入框"> <label> <input type="checkbox" id="sum_5" class="csum" value="5"> </label> </td>
                        <td title="Tab键切换输入框"><input id="colvalue_5"  type="text" class="input-medium"/></td>
                        <td title="Tab键切换输入框"> <label> <input type="checkbox" id="isHide_5" value="5"> </label> </td>、
                        <td><label> <a>删除</a> </label> </td>
                    </tr>

                    <tr>
                        <td><span class="badge">6</span></td>
                        <td title="Tab键切换输入框"> <input id="item_6" type="text" class="input-medium"> </td>
                        <td title="Tab键切换输入框">
                            <select id="coltype_6" class="input-medium">
                                <option value="text">单行输入框</option>
                                <option value="textarea">多行输入框</option>
                                <option value="int">数值</option>
                            </select>
                        </td>
                        <td title="Tab键切换输入框"> <label><input type="text" class="input-mini" id="field_6" value=""> </label> </td>
                        <td title="Tab键切换输入框"> <label><input type="text" class="input-mini" id="unit_6" value=""> </label> </td>
                        <td title="Tab键切换输入框"> <label> <input type="checkbox" id="sum_6" class="csum" value="6"> </label> </td>
                        <td title="Tab键切换输入框"><input id="colvalue_6"  type="text" class="input-medium"/></td>
                        <td title="Tab键切换输入框"> <label> <input type="checkbox" id="isHide_6" value="6"> </label> </td>
                        <td><label> <a>删除</a> </label> </td>
                    </tr>

                    <tr>
                        <td><span class="badge">7</span></td>
                        <td title="Tab键切换输入框"> <input id="item_7" type="text" class="input-medium"> </td>
                        <td title="Tab键切换输入框">
                            <select id="coltype_7" class="input-medium">
                                <option value="text">单行输入框</option>
                                <option value="textarea">多行输入框</option>
                                <option value="int">数值</option>
                            </select>
                        </td>
                        <td title="Tab键切换输入框"> <label><input type="text" class="input-mini" id="field_7" value=""> </label> </td>
                        <td title="Tab键切换输入框"> <label><input type="text" class="input-mini" id="unit_7" value=""> </label> </td>
                        <td title="Tab键切换输入框"> <label> <input type="checkbox" id="sum_7" class="csum" value="7"> </label> </td>
                        <td title="Tab键切换输入框"><input id="colvalue_7"  type="text" class="input-medium"/></td>
                        <td title="Tab键切换输入框"> <label> <input type="checkbox" id="isHide_7" value="7"> </label> </td>
                        <td><label> <a>删除</a> </label> </td>
                    </tr>

                    <tr>
                        <td><span class="badge">8</span></td>
                        <td title="Tab键切换输入框"> <input id="item_8" type="text" class="input-medium"> </td>
                        <td title="Tab键切换输入框">
                            <select id="coltype_8" class="input-medium">
                                <option value="text">单行输入框</option>
                                <option value="textarea">多行输入框</option>
                                <option value="int">数值</option>
                            </select>
                        </td>
                        <td title="Tab键切换输入框"> <label><input type="text" class="input-mini" id="field_8" value=""> </label> </td>
                        <td title="Tab键切换输入框"> <label><input type="text" class="input-mini" id="unit_8" value=""> </label> </td>
                        <td title="Tab键切换输入框"> <label> <input type="checkbox" id="sum_8" class="csum" value="8"> </label> </td>
                        <td title="Tab键切换输入框"><input id="colvalue_8"  type="text" class="input-medium"/></td>
                        <td title="Tab键切换输入框"> <label> <input type="checkbox" id="isHide_8" value="8"> </label> </td>
                        <td><label> <a>删除</a> </label> </td>
                    </tr>
                     -->
                </tbody>
            </table>
        <!--div class="alert alert-danger">提示：</div-->
</div>
<script type="text/javascript">
var oNode = null,thePlugins = 'listctrl';
var rows_count = 8;
var adefaultDatatype = ['text','textarea','int','calc'];

window.onload = function() {
    //弹出窗口初始化函数，这里主要是判断是编辑下拉列表还是新增
    var id = '';
   	editor.ready(function() {
    	 id = editor.queryCommandValue('serverparam').id; //返回参数值键值对的对象
 	});
   	
    if( UE.plugins[thePlugins].editdom ){
        oNode = UE.plugins[thePlugins].editdom;
        $G('orgname').value = oNode.getAttribute('title');

        var gWidth=oNode.getAttribute('orgwidth');
        var pkid = oNode.getAttribute('pkid');
        var fkdsid = oNode.getAttribute('fkdsid');
        var gTitle = oNode.getAttribute('orgtitle'),
                gColType = oNode.getAttribute('orgcoltype'),
                gUnit = oNode.getAttribute('orgunit'),
                gSum = oNode.getAttribute('orgsum'),
                gColValue = oNode.getAttribute('orgcolvalue'),
                gFields = oNode.getAttribute('autofield'),
                isHide = oNode.getAttribute('isHide'),
                ruletype = oNode.getAttribute('ruletype'),
                dict = oNode.getAttribute('dict'),
                length = oNode.getAttribute('length');
                
               
        var aTitle = gTitle.split('`'),
                aColType = gColType ? gColType.split('`') : null,
                aUnit = gUnit ? gUnit.split('`') : null,
                aSum = gSum ? gSum.split('`') : null,
                aColValue = gColValue ? gColValue.split('`') : null,
                aFieldArray = gFields ? gFields.split('`') : null,
                oisHide = isHide ? isHide.split('`') : null,
                oruletype = ruletype ? ruletype.split('`') : null,
                odict = dict ? dict.split('`') : null,
                olength = length ? length.split('`') : null;		
                
       
        $G('orgwidth').value = gWidth;
        $G('pkid').value = pkid;
        $G('fkdsid').value = fkdsid;
        
    	 initDataSource(id);
        if(aFieldArray){
	        if(aFieldArray[0]){
	        	
	        	$("#datasource").val(aFieldArray[0].split('.')[0]);
	        	
	        	//aFieldArray[0]?aFieldArray[0].split('.')[0]:null
	        	$.ajax({
	       			url:'autoFormController.do?getTrList',		
	       			data:{dbName:aFieldArray[0].split('.')[0],autoFormId:id},
	       			async:false,
	       			success:function(data){
	       				var d = $.parseJSON(data);
	       				if(d.success){
	       					$('#tbl1').html('');
	       					$('#tbl1').append($(d.attributes.tableHtml).first()).append($(d.attributes.tableHtml).last());
	       				}
	       			}
	       		}); 
	        }
        }
    	
        for(var i = 0;i < aTitle.length-2; i++){
        	content();
        }
        
        $("#tbl tbody tr:gt(0)").find(":input").removeAttr("disabled");
        
        for ( var i = 0;i < aTitle.length-1; i++ ) {	
        	var sItem = 'item_' + (i + 1),
            sColtype = 'coltype_' + (i + 1),
            sUnit = 'unit_' + (i + 1),
            sNum = 'sum_' + (i + 1),
            sColValue = 'colvalue_' + (i + 1),
            sField = 'field_' + (i + 1),
            sIsHide = 'isHide_' + (i + 1),
            sruletype = 'ruletype_' + (i + 1),
            sdict = 'dict_' + (i + 1),
            slength = 'length_' +(i + 1);
            
            $G(sItem).value = aTitle[i];
            
            $G(sUnit).value = aUnit[i];
			
            $G(sruletype).value = oruletype[i] == '0'?'':oruletype[i];
            
            $G(sdict).value = odict[i] == '0'?'':odict[i];
            $G(slength).value = olength[i] == '#'?'':olength[i];
            
            if(gFields){
            	$('#' + sField).val(aFieldArray[i].split('.')[1]);
            	if(aFieldArray[i].split('.')[1] == 'id' || aFieldArray[i].split('.')[1] == 'ID'){
            		$G(sIsHide).checked = true;
            	} else if(isHide){
            		$G(sIsHide).checked = oisHide[i] == 1 ? true : false;
            	}
            }
            if ( gSum ) {
                $G(sNum).checked = aSum[i] == 1 ? true : false;
            }
            if ( gColType ) {
                $('#' + sColtype).val(aColType[i]);
            }
            if ( gColValue ) {
                if($.inArray(aColType[i],adefaultDatatype) !== -1){
                    $G(sColValue).value = aColValue[i];
                }
            }
        }

    } else {
    	  initDataSource(id);
    }
    //合计，强制选择 int
    $(".csum").click(function(){
        if($(this).attr("checked"))
        {
            var i = $(this).val();
            $("#coltype_"+ i).val('int');
        }

    });
}
dialog.oncancel = function () {
if( UE.plugins[thePlugins].editdom ) {
    delete UE.plugins[thePlugins].editdom;
}
};
dialog.onok = function (){
    if($G('orgname').value==''){
        var selectedField=$('#tbl1').children().eq(0).children().eq(3).children().find("option:selected");
        var flag=false;
        if(selectedField.length>0){
            selectedField=selectedField.get(0);
            if(selectedField.value!=''){
                $G('orgname').value=selectedField.text;
                flag=true;
            }
        }
        if(!flag){
            alert('请输入控件名称');
            $G('orgname').focus();
            return false;
        }
    }
	 var gName=$G('orgname').value.replace(/\"/g,"&quot;"),gWidth=$G('orgwidth').value;
	
    if( gName == '') {
        alert('控件名称不能为空');
        $G('orgname').focus();
        return false;
    }
    
	var datasource = $('#datasource').val();
    var gTitle = '',gColType = '' ,gUnitValue='' ,gSum = '' ,gColValue = '' ,
        nCount = 0,autofield='' ,isHide='' ,ruletype='',dict='',length='';
    rows_count = $('#tbl1 tr').length;
    
    for (var i = 1;i <= rows_count; i ++ ) {
        var oItem  = $G( "item_" + i ) ,
        oSum = $G( 'sum_'+i ) , oColType = $G('coltype_' + i) ,
        oColValue = $G('colvalue_' + i) , oUnit = $G( 'unit_' + i),
        oField = $G('field_' + i) , oisHide = $G('isHide_' + i), oruletype = $('#ruletype_' + i).val(), odict = $('#dict_' + i).val(), olength = $('#length_' + i).val();
        
        
        if(parseInt(olength) != olength){
        	alert('控件长度为整数');
        	$('#length_' + i).focus();
            return false;
        }
        
        if ( oItem.value != '') {
            if(gTitle.indexOf(oItem.value+ '`') !== -1 )
            {
                continue;//重复
            }
            gTitle += oItem.value + '`'; //表头
            nCount ++ ;
            if ( oSum.checked ) { //合计
                gSum += '1`';
            } else {
                gSum += '0`';
            }
            gColType += oColType.value + '`';
            gColValue += oColValue.value + '`';
            gUnitValue += oUnit.value + '`';
            autofield  += datasource+'.'+oField.value + '`';
            if(oruletype == ''){
            	ruletype += '0' + '`';//避免为空，使得后台处理时出错
            } else {
            	ruletype += oruletype + '`';
            }
            if(odict == ''){
            	dict += '0' + '`';
            } else {
            	dict += odict + '`';
            }
          	if(olength == ''){
          		length += '#' + '`';
          	} else {
          		length += olength + '`';
          	}
            if ( oisHide.checked ) {
            	isHide += '1`';
            } else {
            	isHide += '0`';
            }
        }//end if
    }//end for

    if ( nCount == 0 ) {
        alert("表头项目不能为空");
        return false;
    }
	
    var pkid = $G('pkid').value;
    var fkdsid = $G('fkdsid').value;

    if( !oNode ) {

        try {
            oNode = createElement('input','leipiNewField');
            oNode.setAttribute('leipiPlugins',thePlugins );
            oNode.setAttribute('type','text');
            oNode.setAttribute('value','{列表控件}');
            oNode.setAttribute('readonly','readonly');
            oNode.setAttribute('title',gName);
            oNode.setAttribute('autofield',autofield);
            oNode.setAttribute('orgtitle',gTitle);
            oNode.setAttribute('orgcoltype',gColType);
            oNode.setAttribute('orgunit',gUnitValue);
            oNode.setAttribute('orgsum',gSum);
            oNode.setAttribute('orgcolvalue',gColValue);
            oNode.setAttribute('isHide',isHide);
            oNode.setAttribute('ruletype',ruletype);
            oNode.setAttribute('dict',dict);
            oNode.setAttribute('length',length);

            oNode.setAttribute('pkid',pkid);
            oNode.setAttribute('fkdsid',fkdsid);

            if( gWidth != '' ) {
                oNode.style.width = gWidth;
            }
            oNode.setAttribute('orgwidth',gWidth );
            
            editor.execCommand('insertHtml',oNode.outerHTML);
            return true ;
        } catch (e) {
            try {
                editor.execCommand('error');
            } catch ( e ) {
                alert('控件异常，请到 [雷劈网] 反馈或寻求帮助！');
            }
            return false;
        }
    } else {
        //修改
        oNode.setAttribute('leipiPlugins',thePlugins );
        oNode.setAttribute('title',gName);
        oNode.setAttribute('autofield',autofield);
        oNode.setAttribute('orgtitle',gTitle);
        oNode.setAttribute('orgcoltype',gColType);
        oNode.setAttribute('orgunit',gUnitValue);
        oNode.setAttribute('orgsum',gSum);
        oNode.setAttribute('orgcolvalue',gColValue);
        oNode.setAttribute('isHide',isHide);
        oNode.setAttribute('ruletype',ruletype);
        oNode.setAttribute('dict',dict);
        oNode.setAttribute('length',length);
        
        if( gWidth != '' ) {
            oNode.style.width = gWidth;
        }else
        {
            oNode.style.width = '';
        }
        oNode.setAttribute('orgwidth',gWidth );
        
        oNode.setAttribute('pkid',pkid);
        oNode.setAttribute('fkdsid',fkdsid);

        delete UE.plugins[thePlugins].editdom; //使用后清空这个对象，变回新增模式
    }
};

//初始化数据源
function initDataSource(id){
	$.ajax({
			url:'autoFormController.do?getFormDb',		
			data:{autoFormId:id},
			async:false,
   			success:function(data){
				data = $.parseJSON(data);
				$('#datasource').html(data.msg);
				
   			}});
}
$(function(){
	
	//绑定change事件,并填充字段
	$("#datasource").change(function(){
		var dbId = $(this).val();
		id = editor.queryCommandValue('serverparam').id;
		$.post(
			'autoFormController.do?getTrList',		
			{dbName:dbId,autoFormId:id},
			function(data){
				var d = $.parseJSON(data);
				if(d.success){
					$('#tbl1').html('');
					//table内容
					$('#tbl1').html(d.attributes.tableHtml);
					//数据源名称
					$("#orgname").val(d.attributes.dbName);
				}
		});
	});
	
	
	$("#listAdd").click(function(){
		content();
		$("#tbl tbody tr:last").find(":input").removeAttr("disabled");
	});
});

function resetTrNum() {
	$("#tbl tbody tr").each(function(i) {
		$(':input, select', this).each(function() {
		var $this = $(this), id = $this.attr('id'), val = $this.val();
		
		$(this).parent().parent().find("td").eq(0).find("span").html((i+1));
		
		if (id != null) {
		    if(id.indexOf('_')){
	            var subids = id.split('_');
	            var newid = subids[0]+'_'+(i+1);
	            $this.attr('id',newid);
	     	 }else{
	           var newid = id+'_'+(i+1);
	           $this.attr('id',newid);
	         }
		   }
	 });
	});
}

function content(){
	var tbHtml ='<tr>'+ $("#tbl tbody").eq(0).find("tr").eq(0).html().replace('<td></td>',"<td><button class='btn btn-small btn-success delrow' type='button'>删除</button></td>")+'</tr>';
	$("#tbl tbody").eq(0).find("tr:last").after(tbHtml);
	$("#tbl tbody").eq(0).find("tr:last").find("input").each(function(){$(this).val("");});
	$(".delrow").die().live("click",function(){$(this).parent().parent().remove();resetTrNum();});
	resetTrNum();
	$(".delrow").click(function(){$(this).parent().parent().remove();resetTrNum();});
}
</script>
</body>
</html>
